import http from "@/common/http/request";
import { addProductCateInterface, addproductInterface, productCateListInterface, productCateUpdateInterface, productListInterface, productUpdateInterface } from "./product.interface";

//产品列表
export const $getProductList = (data: productListInterface) => {
  const $http = new http();
  return $http.get({
    url: '/hlas/product/list',
    data,
  })
}

//产品详情
export const $productDetail = (id: number) => {
  const $http = new http();
  return $http.get({
    url: `/hlas/product/${id}`
  })
}

//添加产品
export const $AddProduct = (data: addproductInterface) => {
  const $http = new http();
  return $http.post({
    url: '/hlas/product',
    data,
  })
}

//修改产品
export const $productUpdate = (data: productUpdateInterface) => {
  const $http = new http();
  return $http.put({
    url: '/hlas/product',
    data,
  })
}

//删除产品分类
export const $productDelete = (data: Array<string>) => {
  const $http = new http();
  return $http.delete({
    url: `/hlas/product/${data.join(',')}`,
  })
}

//产品分类列表
export const $getProductCateList = (data: productCateListInterface) => {
  const $http = new http();
  return $http.get({
    url: '/hlas/productCate/list',
    data,
  })
}

//产品分类详情
export const $productCateDetail = (id: number) => {
  const $http = new http();
  return $http.get({
    url: `/hlas/productCate/${id}`
  })
}

//编辑产品分类
export const $productCateUpdate = (data: productCateUpdateInterface) => {
  const $http = new http();
  return $http.put({
    url: '/hlas/productCate',
    data,
  })
}

//添加产品分类
export const $AddProductCate = (data: addProductCateInterface) => {
  const $http = new http();
  return $http.post({
    url: '/hlas/productCate',
    data,
  })
}

//删除产品分类
export const $productCateDelete = (data: Array<string>) => {
  const $http = new http();
  return $http.delete({
    url: `/hlas/productCate/${data.join(',')}`,
  })
}

//产品分类树
export const $productCateListTree = () => {
  const $http = new http();
  return $http.get({
    url: '/hlas/productCate/list-tree',
  })
}